﻿namespace RialternativeSample.ViewModels
{
    using System.Collections.ObjectModel;
    using RialternativeSample.Client.Infrastructure;
    using RialternativeSample.Client.Northwind.Interfaces;
    using RialternativeSample.Server.NorthwindService;
    using RialternativeSample.ViewModels.Interfaces;

    public class EmployeesViewModel : Notifier, IEmployeesViewModel
    {
        private ObservableCollection<Employees> employees;

        private IEmployeesDataService employeesDataService;

        public EmployeesViewModel(IEmployeesDataService employeesDataService)
        {
            this.employeesDataService = employeesDataService;
            this.employeesDataService.GetEmployeesAsync(employees => this.Employees = employees);
        }

        public ObservableCollection<Employees> Employees
        {
            get
            {
                return this.employees;
            }

            private set
            {
                this.employees = value;
                this.RaisePropertyChanged(() => this.Employees);
            }
        }
    }
}
